/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package de.up.ling.irtg.gui;

import java.util.List;
import javax.swing.border.TitledBorder;

/**
 *
 * @author koller
 */
public class InterpretationSeedPanel extends javax.swing.JPanel {
    private List<Class> algebraClasses;
    private List<Class> regularSeedClasses;

    /**
     * Creates new form InterpretationSeedPanel
     */
    public InterpretationSeedPanel(String title, List<Class> algebraClasses, List<Class> regularSeedClasses) {
        initComponents();
        
        ((TitledBorder) getBorder()).setTitle("interpretation: " + title);
        
        this.algebraClasses = algebraClasses;
        this.regularSeedClasses = regularSeedClasses;
        
        cbAlgebra.removeAllItems();
        cbAlgebra.addItem("(use original algebra)");
        for( Class c : algebraClasses ) {
            cbAlgebra.addItem(c.getName());
        }
        
        cbRegularSeed.removeAllItems();
        for( Class c : regularSeedClasses ) {
            cbRegularSeed.addItem(c.getName());
        }
    }
    
    public Class getSelectedAlgebra() {
        if( cbAlgebra.getSelectedIndex() == 0 ) {
            return null;
        } else {
            return algebraClasses.get(cbAlgebra.getSelectedIndex()-1);
        }
    }
    
    public Class getSelectedRegularSeed() {
        return regularSeedClasses.get(cbRegularSeed.getSelectedIndex());
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel2 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        cbAlgebra = new javax.swing.JComboBox();
        jLabel3 = new javax.swing.JLabel();
        cbRegularSeed = new javax.swing.JComboBox();

        jLabel2.setText("jLabel2");

        setBorder(javax.swing.BorderFactory.createTitledBorder("interpretation: x"));

        jLabel1.setText("Algebra:");

        cbAlgebra.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        cbAlgebra.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbAlgebraActionPerformed(evt);
            }
        });

        jLabel3.setText("Regular seed:");

        cbRegularSeed.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jLabel3)
                    .add(jLabel1))
                .add(18, 18, 18)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(cbAlgebra, 0, 274, Short.MAX_VALUE)
                    .add(cbRegularSeed, 0, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel1)
                    .add(cbAlgebra, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel3)
                    .add(cbRegularSeed, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void cbAlgebraActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbAlgebraActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_cbAlgebraActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JComboBox cbAlgebra;
    private javax.swing.JComboBox cbRegularSeed;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    // End of variables declaration//GEN-END:variables
}
